from flask import Flask, request
from flask import render_template
# 调用自定义模块中的函数
from reserch import reserch4letters

app = Flask(__name__)


# index
@app.route('/', methods=['GET'])
def hello_world():
    return render_template('welcome.html')


@app.route('/index', methods=['GET'])
def index():
    return render_template('index.html')


@app.route('/indextwo', methods=['GET'])
def indext():
    return render_template('indextwo.html')


# get获取课程表
@app.route('/course', methods=['GET'])
def course():
    return render_template('course.html')


# post 提交后台用于连接名字
@app.route('/result', methods=['POST'])
def result():

    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title() + ' ' + py_lastname.title()

    return render_template('result.html',
                           fullname=py_fullname
                           )

# post 提交后台用于统计字母
@app.route('/resulttwo', methods=['POST'])
def resulttwo():
    py_word = request.form['word']
    py_vowels = request.form['vowels']
    py_found = reserch4letters(py_vowels, py_word)

    return render_template('resulttwo.html', found=py_found)


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000, debug=True)
